package com.coolw.data.migrate.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.concurrent.*;

/**
 * 线程池配置
 *
 * @author coolw
 * @date 2024/2/21 11:11
 */
@Component
public class ThreadPoolConfig {

    /**
     * 数据迁移线程池配置
     */
    @Bean
    public ExecutorService dataMigrateExecutorService() {
        BlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<>(500);
        return new ThreadPoolExecutor(5
                , 10
                , 60L
                , TimeUnit.SECONDS
                , workQueue
                , new ThreadPoolExecutor.CallerRunsPolicy());
    }
}
